//
// Created by A4-28 on 2020/10/16.
//
#include<glad/glad.h>
#include<GLFW/glfw3.h>
#include <iostream>


int main() {
    glfwInit();
    glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3);
    glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3);
    glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE);

    //创建窗口
    GLFWwindow *window = glfwCreateWindow(400, 400, "depthTest", NULL, NULL);
    if (window == NULL) {
        printf("create window error!!");
        glfwTerminate();
    }
    //context
    glfwMakeContextCurrent(window);
    glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);
    //初始glad
    if (!gladLoadGLLoader((GLADloadproc) glfwGetProcAddress)) {
        printf("init glad error");
        glfwTerminate();
    }
    //视口设置
    glViewport(0, 0, 400, 400);
    //开启绘制顶点图元
    glEnable(GL_PROGRAM_POINT_SIZE);

    //渲染
    while (!glfwWindowShouldClose(window)) {

        glClearColor(0.1f, 0.1f, 0.1f, 1.0f);
        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

        glfwPollEvents();
        glfwSwapBuffers(window);
    }

    glfwTerminate();
}

